#!/bin/bash

# 停止Redis服务
echo "Stopping Redis service..."
sudo systemctl stop redis

# 卸载Redis软件包
echo "Uninstalling Redis..."
sudo yum remove redis -y

# 删除Redis数据和配置文件
echo "Removing Redis data and configuration files..."
sudo rm -rf /var/lib/redis
sudo rm -rf /etc/redis

# 清理EPEL仓库（可选）
echo "Cleaning up EPEL repository (if installed)..."
sudo yum remove epel-release -y

# 验证卸载
echo "Verifying Redis uninstallation..."
redis-cli ping 2>/dev/null
if [ $? -eq 0 ]; then
    echo "Redis is still installed. Please check manually."
else
    echo "Redis has been successfully uninstalled."
fi

# 完成卸载
echo "Redis uninstallation completed."